package cu.tedu._05weibo.common.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter

public class JsonResult {
    private Integer code;
    private String msg;
    private Object data;


    public JsonResult(StatusCode statusCode,Object data) {
        this.code=statusCode.getCode();
        this.msg=statusCode.getMsg();
        this.data=data;
    }

    public JsonResult(StatusCode statusCode) {
        this.code=statusCode.getCode();
        this.msg=statusCode.getMsg();
    }


    /**
     静态方法 ok(Object data) , 用于快速创建 JsonResult 对象，表示操作业务成功时返回的响应数据
     */
    public static JsonResult ok(Object data){
        JsonResult resultVo =new JsonResult(StatusCode.SUCCESS,data);
        return resultVo;
    }
    public static JsonResult ok(){
        return ok(null);
    }
}
